home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / portable / printw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  5.9 KB  |  193 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #include <stdarg.h>
  20. #include <string.h>
  21. #define    CURSES_LIBRARY    1
  22. #include <curses.h>
  23.  
  24. /* undefine any macros for functions defined in this module */
  25. #undef    printw
  26. #undef    wprintw
  27. #undef    mvprintw
  28. #undef    mvwprintw
  29.  
  30. /* undefine any macros for functions called by this module if in debug mode */
  31. #ifdef PDCDEBUG
  32. #  undef    waddstr
  33. #  undef    wmove
  34. #endif
  35.  
  36. #ifdef PDCDEBUG
  37. char *rcsid_printw  = "$Id$";
  38. #endif
  39.  
  40. /*man-start*********************************************************************
  41.  
  42.   Name:                                                        printw
  43.  
  44.   Synopsis:
  45.       int printw(char *fmt, ...);
  46.       int wprintw(WINDOW *win, char *fmt, ...);
  47.       int mvprintw(int y, int x, char *fmt, ...);
  48.       int mvwprintw(WINDOW *win, int y, int x, char *fmt,...);
  49.   ***    int vwprintw(WINDOW *win, char *fmt, va_list varglist);
  50.  
  51.   X/Open Description:
  52.      The printw() routine adds a string to the default window
  53.      starting at the current cursor position.  This routine causes
  54.      the string that would normally be output by printf() to be
  55.      output by addstr().
  56.  
  57.      The routine wprintw() adds a string to the specified window
  58.      starting at the current cursor position.  This routine causes
  59.      the string that would normally be output by printf() to be
  60.      output by waddstr().
  61.  
  62.      The routine mvprintw() adds a string to the default window
  63.      starting at the specified cursor position.  This routine
  64.      causes the string that would normally be output by printf() to
  65.      be output by addstr().
  66.  
  67.      The routine mvwprintw() adds a string to the specified window
  68.      starting at the specified cursor position.  This routine
  69.      causes the string that would normally be output by printf() to
  70.      be output by waddstr().
  71.  
  72.      All these routines are analogous to printf().  It is advisable
  73.      to use the field width options of printf() to avoid leaving
  74.      unwanted characters on the screen from earlier calls.
  75.  
  76.   PDCurses Description:
  77.      The old Bjorn Larssen code for the 68K platform has been removed
  78.      from this module.
  79.  
  80.   X/Open Return Value:
  81.      All functions return OK on success and ERR on error.
  82.  
  83.   X/Open Errors:
  84.      No errors are defined for this function.
  85.  
  86.   Portability                             X/Open    BSD    SYS V
  87.                                           Dec '88
  88.       printw                                Y        Y       Y
  89.       wprintw                               Y        Y       Y
  90.       mvprintw                              Y        Y       Y
  91.       mvwprintw                             Y        Y       Y
  92.       vwprintw                              -        -      4.0
  93.  
  94. **man-end**********************************************************************/
  95.  
  96. /***********************************************************************/
  97. int    printw(char *fmt,...)
  98. /***********************************************************************/
  99. {
  100.     int    retval = ERR;
  101.     va_list args;
  102.  
  103. #ifdef PDCDEBUG
  104.     if (trace_on) PDC_debug("printw() - called\n");
  105. #endif
  106.  
  107.     if (stdscr == (WINDOW *)NULL)
  108.         return (retval);
  109.  
  110.     va_start(args, fmt);
  111.     vsprintf(c_printscanbuf, fmt, args);
  112.     va_end(args);
  113.     if (waddstr(stdscr, c_printscanbuf) == ERR)
  114.         return (retval);
  115.     retval = (strlen(c_printscanbuf));
  116.     return (retval);
  117. }
  118. /***********************************************************************/
  119. int    wprintw(WINDOW *win, char *fmt,...)
  120. /***********************************************************************/
  121. {
  122.     int    retval = ERR;
  123.     va_list args;
  124.  
  125. #ifdef PDCDEBUG
  126.     if (trace_on) PDC_debug("wprintw() - called\n");
  127. #endif
  128.  
  129.     if (win == (WINDOW *)NULL)
  130.         return (retval);
  131.  
  132.     va_start(args, fmt);
  133.     vsprintf(c_printscanbuf, fmt, args);
  134.     va_end(args);
  135.     if (waddstr(win, c_printscanbuf) == ERR)
  136.         return (retval);
  137.     retval = (strlen(c_printscanbuf));
  138.     return (retval);
  139. }
  140. /***********************************************************************/
  141. int    mvprintw(int y, int x, char *fmt, ...)
  142. /***********************************************************************/
  143. {
  144.     int    retval = ERR;
  145.     va_list args;
  146.  
  147. #ifdef PDCDEBUG
  148.     if (trace_on) PDC_debug("mvprintw() - called\n");
  149. #endif
  150.  
  151.     if (stdscr == (WINDOW *)NULL)
  152.         return (retval);
  153.  
  154.     if (wmove(stdscr, y, x) == ERR)
  155.         return( retval );
  156.  
  157.     va_start(args, fmt);
  158.     vsprintf(c_printscanbuf, fmt, args);
  159.     va_end(args);
  160.  
  161.     if (waddstr(stdscr, c_printscanbuf) == ERR)
  162.         return( retval );
  163.     retval = (strlen(c_printscanbuf));
  164.     return( retval );
  165. }
  166. /***********************************************************************/
  167. int    mvwprintw(WINDOW *win, int y, int x, char *fmt, ...)
  168. /***********************************************************************/
  169. {
  170.     int    retval = ERR;
  171.     va_list args;
  172.  
  173. #ifdef PDCDEBUG
  174.     if (trace_on) PDC_debug("mvwprintw() - called\n");
  175. #endif
  176.  
  177.     if (win == (WINDOW *)NULL)
  178.         return (retval);
  179.  
  180.     if (wmove(win, y, x) == ERR)
  181.         return (retval);
  182.  
  183.     va_start(args, fmt);
  184.     vsprintf(c_printscanbuf, fmt, args);
  185.     va_end(args);
  186.  
  187.     if (waddstr(win, c_printscanbuf) == ERR)
  188.         return (retval);
  189.     retval = (strlen(c_printscanbuf));
  190.     return (retval);
  191. }
  192.